#include<iostream>
#include<unordered_map>

using namespace std;

class Solution {
public:
    string minWindow(string s, string t) {
        unordered_map<char, int> st;
        unordered_map<char, int> st1;
        string s1;
        size_t set = -1;
        for (auto ch : t) st[ch]++;
        for (int left = 0, right = 0, count = 0; right < s.size(); right++)
        {
            if (st[s[right]] && st1[s[right]]++ < st[s[right]]) count++;
            while (count >= t.size())
            {
                if (st[s[left]] && st1[s[left]]-- <= st[s[left]])
                    count--;
                left++;
                if (set > right - left)
                {
                    set = right - left;
                    s1 = s.substr(left - 1, set);
                }
            }
        }
        return s1;
    }
};

int main()
{
    string s ="ADOBECODEBANC";
    string t = "ABC";
    Solution().minWindow(s, t);
}